package richbar.com.richbar.view.linear;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.common.util.LogUtil;

import java.util.List;

/**
 * Created by qyang on 2018-9-12.
 */

public abstract class LinearLayoutAdapter<T> {
    public Context context;
    private List<T> list;

    public LinearLayoutAdapter(Context context,List<T> list) {
        this.context = context;
        this.list = list;
        LogUtil.e("wrafafafwaw",list);
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public List<T> getList(){
        return list;
    }

    public LayoutInflater getLayoutInflater() {
        if (context != null) {
            return LayoutInflater.from(context);
        }

        return null;
    }

    public int getCount() {
        if (list != null) {
            return list.size();
        }

        return 0;
    }

    public Object getItem(int position) {
        if (list != null) {
            return list.get(position);
        }

        return null;
    }

    /**
     * 供子类复写
     *
     *
     * @param bean
     * @param position
     * @return
     */
    protected abstract View getView(List<T> data,T bean, int position);
}
